﻿
Partial Class GestionDocs
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Si no es Postback lleno los combos.
        If Not IsPostBack Then

            'Lleno Person Type (Tipo de Persona)
            Dim BS_pType As New WebCredit.BusinessRule.PersonType
            Dim pTypes As New System.Collections.Generic.List(Of WebCredit.EntityClass.PersonType_Entity)()
            Dim pType As New WebCredit.EntityClass.PersonType_Entity
            pTypes = BS_pType.GetAll()
            cmbClienteTipo.Items.Clear()
            For Each pType In pTypes
                Dim item As New System.Web.UI.WebControls.ListItem()
                item.Text = pType.Descripcion
                item.Value = pType.id_Tipo
                cmbClienteTipo.Items.Add(item)
            Next
            'Lleno Personas 
            Dim BS_persona As New WebCredit.BusinessRule.Person
            Dim personas As New System.Collections.Generic.List(Of WebCredit.EntityClass.Person_Entity)()
            Dim persona As New WebCredit.EntityClass.Person_Entity
            personas = BS_persona.GetAll()
            cmbPersonaNombre.Items.Clear()

            For Each persona In personas
                Dim item As New System.Web.UI.WebControls.ListItem()
                item.Text = persona.Nombre
                item.Value = persona.id_Persona
                cmbPersonaNombre.Items.Add(item)
            Next



        End If
    End Sub

    Protected Sub btnGuardar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGuardar.Click

        Dim BS_transaction As New WebCredit.BusinessRule.Transaction
        Dim Transaction As New WebCredit.EntityClass.Transaction_Entity

        Transaction.Documento.id_Documento = cmbDocumentoTipo.SelectedValue
        Transaction.FechaMov = txtDocumentoFecha.Text
        Transaction.Importe = txtDocumentoImporte.Text
        Transaction.LetraDoc = "A"
        Transaction.NumeroDoc = txtDocumentoNumero.Text
        Transaction.Observaciones = "sin observaciones"
        Transaction.Persona.id_Persona = cmbPersonaNombre.SelectedValue
        Transaction.SucursalDoc = "Central"
        'Transaction.id_Movimiento

        BS_transaction.Insert(Transaction)

    End Sub
End Class
